-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: replace pre-commit with prek, add PEP 723 script deps, clean up dev dependencies #3748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…up dev dependencies - Replace pre-commit with prek (Rust-native, faster pre-commit alternative) - Move supported hooks to repo: builtin for zero-clone speed - Add new builtin hooks: trailing-whitespace, check-merge-conflict, detect-private-key, check-added-large-files - Update all hook versions to latest (pre-commit-hooks v6, pyupgrade v3.21.2, bandit 1.9.3, uv-pre-commit 0.10.0) - Add PEP 723 inline script metadata to 34 samples with external deps - Remove autogen-agentchat/autogen-ext from dev deps (now declared per-sample) - Remove unused dev deps: pytest-env, tomli-w - Add agent-framework-core>=1.0.0b260130 lower bound to all 21 packages - Update CI workflow to use j178/prek-action - Update docs: DEV_SETUP.md, AGENTS.md, CODING_STANDARD.md, SAMPLE_GUIDELINES.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Modernizes the Python developer tooling for the monorepo by switching from pre-commit to prek, cleaning up workspace dev dependencies, and making samples self-contained via PEP 723 inline metadata.
Changes:
- Replace
pre-commitwithprekacross local tooling and CI, and update hook versions/config. - Add PEP 723 inline script metadata to samples that require external dependencies and document new sample guidelines.
- Normalize non-core packages to depend on
agent-framework-core>=1.0.0b260130and remove unused dev dependencies.
Reviewed changes
Copilot reviewed 64 out of 65 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Removes pre-commit and other no-longer-needed deps; adds prek; updates resolved dependency graph accordingly. |
| python/pyproject.toml | Updates dev dependency group (adds prek, removes pre-commit/unused deps) and renames Poe tasks from pre-commit-* to prek-*. |
| python/.pre-commit-config.yaml | Moves several hooks to repo: builtin, updates hook revisions, and points the Poe hook at prek-check. |
| .github/workflows/python-code-quality.yml | Switches CI job from pre-commit to prek using j178/prek-action@v1 and updates caching paths/keys. |
| python/devsetup.sh | Updates dev setup script to install prek hooks via Poe. |
| python/DEV_SETUP.md | Updates documentation to refer to prek instead of pre-commit and adjusts the suggested commands. |
| python/CODING_STANDARD.md | Documents policy for bumping agent-framework-core lower bounds in non-core packages. |
| python/AGENTS.md | Replaces embedded sample guidance with a link to samples/SAMPLE_GUIDELINES.md. |
| python/.vscode/tasks.json | Updates VS Code task to run prek instead of pre-commit. |
| python/samples/SAMPLE_GUIDELINES.md | Adds explicit sample file structure + PEP 723 dependency guidance and notes on samples syntax checking. |
| python/samples/semantic-kernel-migration/processes/nested_process.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/processes/fan_out_fan_in_process.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/orchestrations/sequential.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/orchestrations/magentic.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/orchestrations/handoff.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/orchestrations/group_chat.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py | Adds PEP 723 metadata and adjusts imports in the orchestration sample. |
| python/samples/semantic-kernel-migration/openai_responses/01_basic_responses_agent.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/openai_responses/02_responses_agent_with_tool.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/openai_responses/03_responses_agent_structured_output.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/openai_assistant/01_basic_openai_assistant.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/openai_assistant/02_openai_assistant_with_code_interpreter.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/openai_assistant/03_openai_assistant_function_tool.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/copilot_studio/01_basic_copilot_studio_agent.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/copilot_studio/02_copilot_studio_streaming.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/chat_completion/01_basic_chat_completion.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/chat_completion/02_chat_completion_with_tool.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/chat_completion/03_chat_completion_thread_and_stream.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/getting_started/observability/agent_with_foundry_tracing.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/getting_started/evaluation/self_reflection/self_reflection.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/getting_started/agents/copilotstudio/copilotstudio_with_explicit_settings.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/demos/chatkit-integration/app.py | Adds PEP 723 metadata to make the demo runnable standalone. |
| python/samples/demos/m365-agent/m365_agent_demo/app.py | Adds PEP 723 metadata at top of file (but currently results in duplicated metadata blocks). |
| python/samples/autogen-migration/single_agent/01_basic_assistant_agent.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/autogen-migration/single_agent/02_assistant_agent_with_tool.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/autogen-migration/single_agent/03_assistant_agent_thread_and_stream.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/autogen-migration/single_agent/04_agent_as_tool.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/autogen-migration/orchestrations/01_round_robin_group_chat.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/autogen-migration/orchestrations/02_selector_group_chat.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/autogen-migration/orchestrations/03_swarm.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/samples/autogen-migration/orchestrations/04_magentic_one.py | Adds PEP 723 metadata to make the sample runnable standalone. |
| python/packages/a2a/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/ag-ui/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/anthropic/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/azure-ai-search/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/azure-ai/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/azurefunctions/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/bedrock/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/chatkit/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/claude/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/copilotstudio/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/declarative/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/devui/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/durabletask/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/foundry_local/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/github_copilot/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/lab/pyproject.toml | Adds core lower bound and replaces pre-commit with prek in the package’s dev group. |
| python/packages/mem0/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/ollama/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/orchestrations/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/purview/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
| python/packages/redis/pyproject.toml | Adds agent-framework-core>=1.0.0b260130 lower bound. |
Comments suppressed due to low confidence (1)
python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py:22
ConcurrentBuilderis used later in this sample (ConcurrentBuilder(participants=[...]).build()), but it is no longer imported after this change. Add the appropriate import (e.g.,from agent_framework.orchestrations import ConcurrentBuilder) or adjust the code to use the correct symbol that is already imported.
Remove global 'files: ^python/' filter and strip python/ prefix from all path patterns in .pre-commit-config.yaml so prek finds files when run from the python/ directory. Update CI workflow to use --cd python instead of --config path. Include trailing whitespace fixes and dev dependency cleanup.
Write a temp pyrightconfig.json matching pyrightconfig.samples.json rules (typeCheckingMode=off, only reportMissingImports and reportAttributeAccessIssue). Filter output to only fail on these rules since syntax-level errors (top-level await, undefined vars) are expected in README documentation snippets.
…list The prek-markdown-code-lint task received all changed files including non-README markdown and files with pre-existing broken imports. Replace with the standard markdown-code-lint task which uses the correct glob patterns (README.md, packages/**/README.md, samples/**/*.md).
- ag-ui: replace TextContent (removed) with content.type == 'text' - durabletask: fix import path to durabletask.worker.TaskHubGrpcWorker - orchestrations: use constructor params instead of .participants() method - observability: mark deprecated code blocks as plain text, filter reportMissingImports to agent_framework modules only - remove README excludes from markdown-code-lint task
Run (package × task) cross-product in parallel using ThreadPoolExecutor and subprocesses. Key changes: - Add scripts/task_runner.py with shared parallel execution engine - Update run_tasks_in_packages_if_exists.py to accept multiple tasks - Update run_tasks_in_changed_packages.py with --files flag and parallel support - Add check-packages poe task (fmt+lint+pyright+mypy in parallel) - Add prek-markdown-code-lint and prek-samples-check with change detection - Split CI code quality workflow into parallel prek and mypy jobs - Update DEV_SETUP.md to document new parallel behavior Core package changes still trigger checks on all packages.
Split the single prek job into parallel jobs: - pre-commit-hooks: lightweight hooks (SKIP=poe-check) - package-checks: fmt/lint/pyright/mypy via check-packages - samples-markdown: samples-lint, samples-syntax, markdown-code-lint - mypy: change-detected mypy checks All 4 jobs run concurrently (×2 Python versions = 8 runners).
Add `from __future__ import annotations` to 93 package files that used quoted string annotations, then run pyupgrade --py310-plus to remove the now-unnecessary quotes. Fixes microsoft#3578
Summary
This PR modernizes the Python tooling and dependency management across the monorepo.
Fixes #3578
Changes
Parallelize checks across packages
scripts/task_runner.py— shared parallel execution engine usingThreadPoolExecutorrun_tasks_in_packages_if_exists.pyto accept multiple tasks and run (package × task) cross-product in parallelrun_tasks_in_changed_packages.pywith--filesflag and parallel supportcheck-packagespoe task that runs fmt+lint+pyright+mypy in parallel across all 22 packagesprek-markdown-code-lintandprek-samples-checkwith change detection (skip when irrelevant files changed)Split CI code quality into parallel jobs
SKIP=poe-checkto run lightweight pre-commit hooks separately from heavy package checksAdd
from __future__ import annotationsand remove quoted typesfrom __future__ import annotationsto 81 package files that used quoted string annotationspyupgrade --py310-plusto remove the now-unnecessary quotes@handler/@response_handlerdecorators)Replace pre-commit with prek
repo: builtinfor zero-clone, Rust-native execution: check-toml, check-yaml, check-json, end-of-file-fixer, mixed-line-endingPEP 723 inline script metadata for samples
Dev dependency cleanup
Core version lower bounds
Documentation updates